package org.example.script;

import com.alibaba.fastjson.JSONObject;
import org.example.HttpSend;
import org.example.leetcode.core.dto.SysUserRegisterDto;

import java.util.Random;

/**
 * @author topto
 * 注册脚本
 */
public class RegisterScript {
    public static void main(String[] args) throws Exception {
        String url="http://127.0.0.1:8000/core/sys-user/register";
        for(int i=0;i<100;i++){
            SysUserRegisterDto sysUserRegisterDto=new SysUserRegisterDto();
            sysUserRegisterDto.setPhone(generatePhone());
            sysUserRegisterDto.setPassword("1234");
            sysUserRegisterDto.setPasswordConfirm("1234");
            sysUserRegisterDto.setCode("1");
            String s = JSONObject.toJSONString(sysUserRegisterDto);
            String res = HttpSend.sendHttp(url, s,"POST",null);
            System.out.println(res);
        }
    }
    public static String generatePhone(){
        Random r=new Random();
        StringBuilder sb=new StringBuilder();
        for(int i=0;i<11;i++){
            int x = r.nextInt(10);
            sb.append(x);
        }
        return sb.toString();
    }
}
